package club.hicode.daydayup.threadpool;

import cn.hutool.core.thread.ThreadUtil;
import org.junit.Test;

import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

/**
 * 线程中端的测试
 *
 * @author Liu Chunfu
 * @date 2018-06-26 上午9:32
 **/
public class ThreadInterTest {

    @Test
    public void test1() throws InterruptedException {
        Thread thread = new Thread(() -> {
            System.out.println(123);
            ThreadUtil.sleep(5, TimeUnit.SECONDS);
            System.out.println("over");
        });
        //thread.join();
        thread.start();
        //肯定会被执行到，因为happenbefor规则定义了，线程的所有操作肯定在线程结束之前
        thread.join();

        System.out.println("end");

        Executors.newSingleThreadExecutor();

    }
}
